package org.example.eurekaopenfeignclient.controller;

import org.example.eurekaopenfeignclient.entity.Product;
import org.example.eurekaopenfeignclient.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    ProductService productService;

    @RequestMapping(value = "/get1", method = RequestMethod.GET)
    public String get_product1() {
        return productService.get_product("电视", 1568);
    }

    @RequestMapping(value = "/get2", method = RequestMethod.GET)
    public String get_product2() {
        return productService.get_product(new Product(12, "洗衣机", "2023.11", 1200));
    }

    @RequestMapping(value = "/get3/{name}/{price}/{date}",method = RequestMethod.GET)
    public  String get_product(@PathVariable String name, @PathVariable float price, @PathVariable String date)
    { return "利用@PathVariable注解接收参数，商品名为："+name+"价格为："+price; }
}
